home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / prog / dict / hash_dic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  360 b   |  24 lines

  1. #include <LEDA/hash.h>
  2.  
  3.  
  4. int hash_fun(const string& x) { return int(x[0]); }
  5.  
  6. main()
  7. {
  8.   hash<string,int> D(hash_fun);
  9.  
  10.   hash_item it;
  11.   string r;
  12.  
  13.   while (cin >> r)
  14.     { it = D.lookup(r);
  15.       if (it==nil) D.insert(r,1);
  16.       else D.change_inf(it,D.inf(it)+1);
  17.      }
  18.  
  19.   forall_items(it,D) cout <<  D.inf(it) << " " << D.key(it) << "\n";
  20.  
  21.   return 0;
  22. }
  23.  
  24.